package cn.iocoder.yudao.module.vr.dal.mysql.testoption;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.vr.controller.admin.testoption.vo.*;
import cn.iocoder.yudao.module.vr.dal.dataobject.testoption.TestOptionDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 试题选项 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TestOptionMapper extends BaseMapperX<TestOptionDO> {

    default PageResult<TestOptionDO> selectPage(TestOptionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TestOptionDO>()
                .eqIfPresent(TestOptionDO::getTestId, reqVO.getTestId())
                .eqIfPresent(TestOptionDO::getOrderId, reqVO.getOrder())
                .eqIfPresent(TestOptionDO::getContent, reqVO.getContent())
                .eqIfPresent(TestOptionDO::getCorrect, reqVO.getCorrect())
                .eqIfPresent(TestOptionDO::getPictureUrl, reqVO.getPictureUrl())
                .betweenIfPresent(TestOptionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TestOptionDO::getId));
    }

    default List<TestOptionDO> selectList(TestOptionExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TestOptionDO>()
                .eqIfPresent(TestOptionDO::getTestId, reqVO.getTestId())
                .eqIfPresent(TestOptionDO::getOrderId, reqVO.getOrder())
                .eqIfPresent(TestOptionDO::getContent, reqVO.getContent())
                .eqIfPresent(TestOptionDO::getCorrect, reqVO.getCorrect())
                .eqIfPresent(TestOptionDO::getPictureUrl, reqVO.getPictureUrl())
                .betweenIfPresent(TestOptionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TestOptionDO::getId));
    }

    default List<TestOptionDO> selectListByTestId(Long testId) {
        return selectList(new LambdaQueryWrapperX<TestOptionDO>()
                .eqIfPresent(TestOptionDO::getTestId, testId)
                .orderByAsc(TestOptionDO::getOrderId));
    }

}
